package zozopo.background.operator;

import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.LimitedOS;
import zozopo.background.operator.operations.LimitedTB;
import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;


import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class InsertOperatorlimitedAction extends ActionSupport implements Action,SessionAware{
	//传入参数
	private String searchStr = "";
	//分页参数
	private int beginPageNum = 0;
	private int pageSize = 15;
	private int rowNum = 0;
	//传出参数
	
	private List<LimitedTB> limitedList;

	private Map<Object, Object> session;
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	public String execute(){
		
		//权限处理
		UserTB user = (UserTB) session.get("userInfo");
		if(user == null){
			return NONE;
		}
		if(!UserOS.userFlagLeve(user, 17, 1)){  //系统级权限
			return NONE;
		}//*/
		
		
		
		
		LimitedOS limitedOS = new LimitedOS();
		
		if(searchStr.equals("")){
			limitedList = limitedOS.selectAll(beginPageNum, pageSize);
			
			
			rowNum = limitedOS.getRowNum();
		}else{
			limitedList = limitedOS.selectBySearchStr(searchStr,beginPageNum, pageSize);
			rowNum = limitedOS.getRowNumForSearchStr(searchStr);
		}
		
		
		limitedOS.releaseConnection();
		
		return SUCCESS;

	}
	
	public String getSearchStr() {
		return searchStr;
	}
	public void setSearchStr(String searchStr) throws UnsupportedEncodingException {
		this.searchStr = java.net.URLDecoder.decode(searchStr, "UTF-8");
		
	}
	public int getBeginPageNum() {
		return beginPageNum;
	}
	public void setBeginPageNum(int beginPageNum) {
		this.beginPageNum = beginPageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getRowNum() {
		return rowNum;
	}
	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}
	
	public List<LimitedTB> getLimitedList() {
		return limitedList;
	}
	public void setLimitedList(List<LimitedTB> limitedList) {
		this.limitedList = limitedList;
	}

}
